package com.HQCourse.live.controller.api;

import com.HQCourse.live.service.LiveCourseService;
import com.HQCourse.result.Result;
import com.HQCourse.utils.AuthContextHolder;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


import java.util.Map;

@RestController
@RequestMapping("api/live/liveCourse")
public class LiveCourseApiController {
    @Autowired
    private LiveCourseService liveCourseService;


        @ApiOperation(value = "获取用户access_token")
        @GetMapping("getPlayAuth/{id}")
        public Result<JSONObject> getPlayAuth(@PathVariable Long id) {
            JSONObject object = liveCourseService.getAccessTocken(id, AuthContextHolder.getUserId());
            return Result.ok(object);
        }
        @ApiOperation("根据id查询")
       @GetMapping("getInfo/{courseId}")
       public Result getInfo(@ApiParam(value="课程id" ,required = true)
                          @PathVariable("courseId") Long id){
            Map<String,Object> map=liveCourseService.getInfoById(id);
        return Result.ok(map);
        }

    }

